<?php

use yii\db\Migration;
use yii\db\Schema;

class m170711_095813_ADD_TABLE_ORDER_CHANGE_REQUEST extends Migration
{
    public function up()
    {

        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

        // 游轮基础信息
        $this->createTable('order_refund', [
            "id" =>           Schema::TYPE_PK,
            "product_id" =>	  Schema::TYPE_INTEGER.   "(11) NOT NULL COMMENT '对应航线 ID'",
            "order_id" =>	  Schema::TYPE_INTEGER.   "(11) NOT NULL COMMENT '订单 ID'",
            "order_room_id"=> Schema::TYPE_INTEGER.   "(11) NOT NULL COMMENT '订单舱房 ID'",
            "room_price" =>   Schema::TYPE_DECIMAL.   "(10,2) DEFAULT NULL COMMENT  '舱房金额'",
            "price" =>        Schema::TYPE_DECIMAL.   "(10,2) DEFAULT NULL COMMENT  '金额(审批实际退给的金额)'",
            "desc" =>         Schema::TYPE_STRING.    "(255) NULL COMMENT '取消原因'",
            "user_id" =>      Schema::TYPE_INTEGER.   "(10) DEFAULT '0' COMMENT '申请人编号'",
            "examine_id" =>   Schema::TYPE_INTEGER.   "(11) NULL  COMMENT '审批人ID'",
            "params" =>       Schema::TYPE_STRING.    "(1024) NULL COMMENT '取消订单的记录参数'",


            "status" =>       Schema::TYPE_INTEGER.   "(1) DEFAULT  '1' COMMENT '1申请中  2 已审批'",
            "created_at" =>   Schema::TYPE_DATETIME.  " NULL COMMENT '创建时间  即申请时间 '",
            "check_at" =>     Schema::TYPE_DATETIME.  " NULL COMMENT '审批时间' ",
            "updated_at" =>   Schema::TYPE_TIMESTAMP. " NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP",
        ], $tableOptions);


    }



    public function down()
    {
        echo "m170711_095813_ADD_TABLE_ORDER_CHANGE_REQUEST cannot be reverted.\n";

        return false;
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
